package com.example.administrator.sizhang_jineng;

import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    private ImageView mImg;
    private TextView mTv;
    private Timer mTr;
    int a=5;
     Handler  mHandler=new Handler(){
         @Override
         public void handleMessage(Message msg) {
             a--;
            if(a>0){
                mTv.setText(a+"");
            }else{
                Intent in=new Intent(MainActivity.this,Tu2.class);
                startActivity(in);
                mTr.cancel();

            }
         }
     };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        DaoJiShi();
        initView();
    }

    private void DaoJiShi() {
        mTr = new Timer();
        TimerTask tk=new TimerTask() {
            @Override
            public void run() {
             mHandler.sendEmptyMessage(10);
            }
        };
        mTr.schedule(tk,1000,1000);
    }

    private void initView() {
        mImg = (ImageView) findViewById(R.id.img);
        mTv = (TextView) findViewById(R.id.tv);
        ObjectAnimator  ob=ObjectAnimator.ofFloat(mImg,"scaleY",0.1f,1.0f);
        ob.setDuration(5000);
        ob.start();
    }
}
